public class Fight {
    public static void main(String[] args)
    {
        Tank tk = new Tank(10, 20);
        for(int i = 0;i < 22;i++){
            tk.fire();
        }
        tk.state();
        tk.setBulletAmount(15);
        tk.speedDown();
        tk.speedUp();
        tk.speedUp();
        tk.state();
    }
}


class Tank {
    private double speed;
    private int bulletAmount;

    public Tank(double speed, int bulletAmount)
    {
        this.speed = speed;
        this.bulletAmount = bulletAmount;
    }

    public void speedUp()
    {
        if(this.speed < 20)
            this.speed = this.speed + 1;
        System.out.println("加速，当前车速: " + this.speed);
    }
    public void speedDown()
    {
        if(this.speed > 0)
            this.speed = this.speed - 1;
        System.out.println("减速，当前车速: " + this.speed);
    }

    public void fire()
    {
        if(this.bulletAmount == 0)
            System.out.println("你的抢里没有子弹~");
        else {
            this.bulletAmount = this.bulletAmount - 1;
            System.out.println("开炮!" + "炮弹剩余数量: " + this.bulletAmount);
        }
    }

    public void state()
    {
        System.out.println("车速: " + this.speed + " 炮弹剩余数量: " + this.bulletAmount);
    }

    public void setBulletAmount(int p)
    {
        this.bulletAmount = p;
        System.out.println("装弹: " + this.bulletAmount);
    }

}
